package com.vaadin.thomas.contenttool.data.impl;

import org.neo4j.graphdb.Node;

class NodeUtil {

	public static int getInt(Node n, String prop) {

		Object value = n.getProperty(prop);

		if (value == null) {
			throw new RuntimeException("not a number");
		}

		if (value instanceof Integer) {
			return (Integer) value;
		}
		if (value instanceof String) {
			try {
				return Integer.valueOf((String) value);
			} catch (NumberFormatException e) {
			}
		}

		throw new RuntimeException("not a number");
	}

}
